home *** CD-ROM | disk | FTP | other *** search
- // Dynamic link library implementation of NeuroSolutions BackLinearAxon component using the performBackAxon protocol
-
- #include "NSDLL.h"
-
- /* Backpropagation of component */
-
- __declspec(dllexport) void performBackAxon(
- void *instance, // Pointer to instance data
- void *dualInstance, // Pointer to the forward axons instance data
- NSFloat *data, // Pointer to the layer of processing elements (PEs)
- int rows, // Number of rows of PEs in the layer
- int cols, // Number of columns of PEs in the layer
- NSFloat *error // Pointer to the sensitivity vector
- )
- {
- int i,length=rows*cols;
- NSFloat *gradient = getWeights(instance);
- NSFloat beta = getFloatParameter(dualInstance, 2, 1);
-
- for (i=0; i<length; i++) {
- error[i] *= beta;
- gradient[i] += error[i];
- }
- }
-
- /******************************************/
- /* Management of instance data (OPTIONAL) */
-
- __declspec(dllexport) DLLData *allocBackAxon(
- DLLData *oldInstance, // Pointer to the last instance if reallocating
- DLLData *dualInstance, // Pointer to forward axonÆs instance data (may be NULL)
- int rows, // Number of rows of PEs in the layer
- int cols // Number of columns of PEs in the layer
- )
- {
- DLLData *instance = allocDLLInstance(oldInstance);
- setWeights(instance, rows*cols);
- return instance;
- }
-
- __declspec(dllexport) void freeBackAxon(DLLData *instance)
- {
- freeDLLInstance(instance);
- }
-
-